package com.it.whitejotterapi.config;

import com.it.whitejotterapi.tools.JsonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: 羡羡
 * @Date: 2022/05/23/18:28
 */
@ControllerAdvice
public class SysExecptionHandler extends Throwable{
    /**
     * ajax异常
     * @param ex
     * @return
     */
    @ExceptionHandler(value = AjaxExecption.class)
    @ResponseBody
    public JsonResult handleAjax(HttpServletRequest request, HttpServletResponse response, Exception ex){
        JsonResult js=new JsonResult(500,ex.getMessage());
        return js;
    }
}
